package com.example.springboot.service;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.springboot.entity.Orders;
import com.example.springboot.mapper.OrdersMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 业务处理
 **/
@Service
public class OrdersService extends ServiceImpl<OrdersMapper, Orders> {

    @Resource
    OrdersMapper ordersMapper;

    /**
     * 新增
     */

    public void add(Orders orders) {
        orders.setOrderNo(IdUtil.getSnowflakeNextIdStr());
        orders.setStatus("待支付");
        orders.setCreateTime(DateUtil.now());
        ordersMapper.insert(orders);
    }

    public Orders selectByOrderNo(String orderNo) {
        return ordersMapper.selectByOrderNo(orderNo);
    }

}
